home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / crcfast.com / CRC.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-07-14  |  1.4 KB  |  51 lines

  1. ; Assembler interface to Turbo Pascal - CRC Unit
  2. ;
  3. ; Copyright 1988 by Mark R. Boler  -  All Rights Reserved
  4.  
  5. TITLE    CRC
  6.  
  7. CODE     SEGMENT BYTE PUBLIC
  8.  
  9.          ASSUME  CS:CODE
  10.  
  11.          PUBLIC  CalcCrc
  12.  
  13. ; PROCEDURE CalcCrc(b: BYTE; VAR TheCrc: WORD); EXTERNAL;
  14.  
  15. TheByte  EQU     BYTE  PTR ss:[bx + 8]
  16. TheCRC   EQU     DWORD PTR ss:[bx + 4]
  17.  
  18. ; WARNING: This procedure must not destroy: ss, sp, ds, bp, cx or si
  19.  
  20. CalcCrc  PROC    FAR
  21.          mov     bx, sp                 ; set up stack frame in bx
  22.          mov     al, TheByte            ; get the byte into al
  23.          les     di, TheCRC             ; get address of the crc value
  24.          mov     bx, es:[di]            ; get old crc in bx
  25.          xor     ah, ah                 ; compute the crc
  26.          xor     al, bh
  27.          mov     bh, bl
  28.          mov     bl, al
  29.          mov     dl, al
  30.          and     dl, 0F0H
  31.          xor     bh, dl
  32.          rol     ax, 1
  33.          xor     bh, ah
  34.          mov     dl, al
  35.          and     dl, 0E0H
  36.          xor     bl, dl
  37.          rol     ax, 1
  38.          rol     ax, 1
  39.          rol     ax, 1
  40.          xor     bl, ah
  41.          xor     bh, al
  42.          rol     ax, 1
  43.          xor     ax, bx
  44.          mov     es:[di], ax            ; store the result
  45.          ret     6                      ; clean up and return to caller
  46. CalcCrc  ENDP
  47.  
  48. CODE     ENDS
  49.  
  50.          END
  51.